<template>
    <div class="page">
        <div class="bg">
            <img :src="`${_oss_}images/mobile/template/bg.jpg`" />
        </div>

        <div class="title-group">
            <div class="title">{{ name }}</div>
            <SearchGroupM @search="onSearch" />
        </div>

        <TabsGroupM v-model:active="tabActive" :list="tabList" />

        <div class="case-list" v-if="JSON.stringify(list) != '[]'">
            <template v-if="Array.isArray(list)">
                <TabsGroupM v-model:active="tabActive2" :list="tabList2" />
                <template v-if="Array.isArray(list[tabActive2].child[0].child)">
                    <template
                        v-for="item2 in list[tabActive2].child"
                        :key="item2.id"
                    >
                        <div class="cell-title">{{ item2["name"] }}</div>
                        <CaseGroupM :list="item2.child" :keyword="keyword" />
                    </template>
                </template>
                <CaseGroupM
                    v-else
                    :list="list[tabActive2].child"
                    :keyword="keyword"
                />
            </template>

            <CaseGroupM :list="list.child" :keyword="keyword" v-else />
        </div>
    </div>
</template>
<script setup>
import { ref } from "vue";
import { useContent } from ".";

const keyword = ref("");
const {
    onGetCaseList,
    onGetCaseCate,
    name,
    tabActive,
    tabActive2,
    tabList,
    tabList2,
    list,
} = useContent();

const onSearch = (value) => {
    keyword.value = value;
};

onMounted(async () => {
    await nextTick();
    onGetCaseCate();
    onGetCaseList();
});
</script>
<style lang="scss" scoped>
.page {
    background-color: #f5f5f5;
    min-height: calc(100vh - 44px);

    .bg {
        width: 100%;

        img {
            display: block;
            width: 100%;
        }
    }
    .title-group {
        padding: 15px;
        font-size: 17px;
        color: #333;
        font-weight: 500;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}

.case-list {
    padding: 0 15px;

    .tab-list {
        margin: 0;
    }

    .cell-title {
        position: relative;
        padding-left: 12px;
        margin-top: 15px;
        color: #5085fb;
        line-height: 16px;
        user-select: none;
        font-size: 14px;

        &-2 {
            color: #333;
            text-align: center;
            font-weight: bold;
            font-size: 18px;
        }

        &::after {
            content: "";
            width: 2px;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            background-color: #5085fb;
            border-radius: 2px;
            overflow: hidden;
        }
    }
}
</style>
